﻿using System;
using Fuse8.ContentManagementFramework.DataAccess.SqlAccess.Commands;
using Fuse8.ContentManagementFramework.DataAccess.SqlAccess.Mappers;
using Fuse8.ContentManagementFramework.Domain;
using Fuse8.ContentManagementFramework.Domain.Commands;
using Fuse8.ContentManagementFramework.SystemFacade.Utilities;
using Fuse8.DomainFramework.Common.Locator;
using Fuse8.DomainFramework.DataAccess;
using Fuse8.DomainFramework.DataAccess.SqlDatabase;
using Fuse8.DomainFramework.Domain;

namespace Fuse8.ContentManagementFramework.DataAccess.Contents
{
    public static class ContentItemDataAccessPolicy
    {
         public static void Register<TEntity>() where TEntity : class, IContentItem, IEntityObject<int>, new()
         {
             var container = DependencyServiceLocator.Current;

             container.Register(
                 SqlEntityDataRepositoryConfiguration<TEntity, int>.CreateUnitOfWorkFactory(
                     CmsDataRepositoryConfiguration.DefineConnectionString(typeof (CmsContent))));

             container.Register<ISqlEntityDataMapper<TEntity, int>>(new CmsBaseSqlEntityDeepDataMapper<TEntity, int>());
             var cmsContentTypeRepository = SqlEntityDataRepositoryConfiguration<TEntity, int>.CreateMixedRepository();            
             container.Register<IEntityDataRepository<TEntity, int>>(cmsContentTypeRepository);             
         }
    }
}